<?php
class M_estadistica extends CI_Model {
	function _construct(){
		//Call the Model constructor
		parent::_construct();
	}
	
	function getVisitasDeHoy($idSxC=null, $hora=null){
		 $consulta = $this->db->query("SELECT COUNT(*) AS cantidad
									   FROM (  SELECT *
												FROM auditoria
												WHERE que=7 AND quien=".$this->db->escape($idSxC)." AND DATE_FORMAT(fechaCreacion,'%d/%m/%Y %k') = DATE_FORMAT(now(),'%d/%m/%Y ".$this->db->escape($hora)."')
												GROUP BY donde, navegador
											 ) AS Tab");
        return($consulta);	
	}
	
	function getVisitasPorDia($idSxC=null, $dia=null){
		 $consulta = $this->db->query("SELECT COUNT(*) AS cantidad
									   FROM (  SELECT *
												FROM auditoria
												WHERE que=7 AND quien=".$this->db->escape($idSxC)." AND DATE_FORMAT(fechaCreacion,'%e/%m/%Y') = DATE_FORMAT(now(),'".$this->db->escape($dia)."/%m/%Y')
												GROUP BY donde, navegador
											 ) AS Tab");
        return($consulta);	
	}
	
	function getVisitasPorMes($idSxC=null, $mes=null){
		 $consulta = $this->db->query("SELECT COUNT(*) AS cantidad
									   FROM (  SELECT *
												FROM auditoria
												WHERE que=7 AND quien=".$this->db->escape($idSxC)." AND DATE_FORMAT(fechaCreacion,'%c/%Y') = DATE_FORMAT(now(),'".$this->db->escape($mes)."/%Y')
												GROUP BY donde, navegador
											 ) AS Tab");
        return($consulta);	
	}
}
?>